package com.ysd.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.News;
import com.ysd.utli.DBManager;

public class NewszhuyeDaolmpl {
 public List<News> getNews(){
  List<News> list = new ArrayList<News>();
  Connection conn = DBManager.getConnection();
  Statement st = null;
  ResultSet rs = null;
  try {
   st = conn.createStatement();
   String sql = "select * from news";
   rs = st.executeQuery(sql);
   while(rs.next()) {
	   int newsid = rs.getInt("newsid");
		String newsTitle = rs.getString("newsTitle");
		String newsContent = rs.getString("newsContent");
		String newsCategoryid = rs.getString("newsCategoryid");
		String newsZhuYe = rs.getString("newsZhuYe");
		News news =new News(newsid, newsTitle, newsContent, newsCategoryid, newsZhuYe);
		list.add(news);
   }
   return list;
  } catch (SQLException e) {
   e.printStackTrace();
   return null;
  }finally {
   DBManager.closeAll(conn, st, rs);
  }
 }
}